﻿/// <reference path="vs11.base.js" />
/// <reference path="dom.js" />
$vs11.server = {}; $vs11.request = []; $vs11.response = {}; $vs11.browser = { isIE: (document.all != null) };
$vs11.doc = {}; $vs11.parser = {}; $vs11.config = { isDebug: true, rootPath: "/", isOneDesktop: false };
$vs11.pager = {}; $vs11.win = {}; $vs11.ajax = {}; vs11.UI = {};
//#region request机制,支持request[paramName]直接取get参数
$vs11.request.Runer = function () {
	var search = document.location.search;
	if (search == "" || search == "?") return;
	if (search.substr(0, 1) == "?") search = search.substr(1);
	var arr = search.split("&");
	for (var i = 0, count = arr.length; i < count; i++) {
		var paramArr = arr[i].split("="); var n = paramArr[0]; var v = paramArr[1];
		if (n == "Runer") continue;
		this[n] = (this[n] == null)
            ? v : ((this[n].constructor == Array)
                ? this[n].concat([v]) : [this[n], v]);
	}
}; if (!$vs11.designMode) $vs11.request.Runer();
//#endregion
//#region 基本对象原型prototype扩展,Date.prototype.format,Number.prototype.formatZero
if (Date.prototype.format == null) Date.prototype.format = function (format) {
	var regs = [/yyyy/g, /MM/g, /dd/g, /HH/g, /mm/g, /ss/g]; var regs2 = [/yy/g, /M/g, /d/g, /H/g, /m/g, /s/g];
	var values = [this.getFullYear(), this.getMonth() + 1, this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()];
	for (var i = 0; i < 6; i++) { format = format.replace(regs[i], (values[i] > 9) ? values[i] : "0" + values[i]); format = format.replace(regs2[i], values[i]); }
	return format;
}
Number.prototype.formatZero = function (zero) {
	var arr = zero.split("."); var str = "" + this; var next = str.split(".");
	var need = ["0000000000000000000000000000000000", "00000000000000000000000000000000"];
	next[0] = (arr[0].length > next[0].length) ? need[0].substr(0, arr[0].length - next[0].length) + next[0] : next[0];
	next[1] = (arr[1].length > next[1].length) ? need[1].substr(0, arr[1].length - next[1].length) + next[1] : next[1];
	return next.join(".");
}
//#endregion
//#region 基本对象类型的静态方法[String.format,Object.isLinkAvoid,Object.isNull,Object.isNullOrEmpty,Date.ParseEnyFormat]
if (String.format == null) String.format = function (string, args) {
	var reg, val; for (var i = 0, count = arguments.length - 1; i < count; i++) {
		reg = new RegExp("[\u007B]{1}" + i + "[\}]{1}", "g"); val = arguments[i + 1];
		if (val == null) break; string = string.replace(reg, val);
	}
	return string;
}
Object.isLinkAvoid = function (val) {
	try { var a = val.constructor; } catch (e) { return true; } return false;
}
Object.isNull = function (value, replace) {
	return (replace == null) ? (value == null) : ((value == null) ? replace : value);
}
Object.isNullOrEmpty = function (obj, value) {
	return (value == null)
	? (obj == null || (typeof (obj) == "number" && isNaN(obj)) || obj === "")
	: ((obj == null || (typeof (obj) == "number" && isNaN(obj)) || obj === "") ? value : obj);
}
Date.ParseEnyFormat = function (dateString) {
    ///<summary>任意数字日期时间字符串的解析，解析失败就返回null</summary>
    ///<param name="dateString">要格式化的日期字符串</param>
    var parseReg = /[^0-9]+/g;
    var arr = ("" + dateString).split(parseReg);
    var len = arr.length;
    if (!(len == 3 || len >= 5)) return null;
    var yearPos = -1;
    for (var i = 0; i < len; i++) { if (parseInt(arr[i], 10) > 31) { yearPos = i; break; } }
    var date;
    if (yearPos == -1 && len == 3) {//只有时间
        date = new Date();
        date.setHours(parseInt(arr[0], 10), parseInt(arr[1], 10), parseInt(arr[2], 10));
        return date;
    } else if ((yearPos == 0 || yearPos == 2)) {
        date = new Date();
        if (yearPos == 0) {
            date.setFullYear(parseInt(arr[0], 10), parseInt(arr[1], 10) - 1, parseInt(arr[2], 10));
        } else {
            date.setFullYear(parseInt(arr[2], 10), parseInt(arr[0], 10) - 1, parseInt(arr[1], 10));
        }
        if (len >= 5) {
            var hours = parseInt(Object.isNull(arr[3], 0), 10);
            if (hours > 100) {
                date.setHours(0, 0, 0, 0);
            } else {
                date.setHours(hours, parseInt(Object.isNull(arr[4], 0), 10),
                parseInt(Object.isNull(arr[5], 0), 10),
                parseInt(Object.isNull(arr[6], 0), 10));
            }
        } else {
            date.setHours(0, 0, 0, 0);
        }
        return date;
    } else {
        return null;
    }
}

//#endregion
//#region 页面装载的支持[$vs11.load(loader),$vs11.loadOnce(loader)]
$vs11.addEvent(document, "VS11PageLoad");
document.OnVS11PageLoad_End.push(function () { document.VS11PageLoad_OK = true; });
$vs11.addHandler(window, "load", function () {
	window.setTimeout(document.VS11PageLoad, 0);
});
$vs11.load = function (loader) {
	if (document.VS11PageLoad_OK) window.setTimeout(loader, 1)
	else document.OnVS11PageLoad.push(loader);
}
$vs11.loadOnce = function (loader) {
	var isOnce = document.OnVS11PageLoad.safePush(loader);
	if (document.VS11PageLoad_OK && isOnce) window.setTimeout(loader, 1)
}
//#endregion
//#region browser机制[暂无具体实现,仅在定义时指定isIE属性]
//#endregion
//#region server机制[mapPath(rootTagPath),依赖于$vs11.config.rootPath的值]
$vs11.server.mapPath = function (rootTagPath) {
	return rootTagPath.replace(new RegExp("^~\\/"), $vs11.config.rootPath);
}
//#endregion
//#region 基础类型[vs11.Object]
MyClass = vs11.Object = function (args) {
	//#region 类型化,支持受保护的继承变量域
	if (args == null) args = {}; var q = (this.Inheriting) ? args : {}; this.Inheriting = true;
	var $vs = $vs11, vs = vs11;
	var protected$ = q, Me = public$ = this, v = private$ = {}, base = $vs.copyObject(q);
	//#endregion
	Me.BaseType = "vs11.Object";
	Me.BaseVersion = "vs1.0";
	//#region 方法
	Me.Despose = Me.Destroy = q.Destroy = function () {
		for (prop in v) { delete (v[prop]); } for (prop in base) { delete (base[prop]); }
		for (prop in q) { delete (q[prop]); } for (prop in Me) { delete (Me[prop]); }
		if (CollectGarbage) { CollectGarbage(); window.setTimeout("try{CollectGarbage();}catch(e){}", 1); }
	}
	Me.toString = function () { return $vs.parser.parserOne(this); }
	//#endregion
	//#region 基础分类域[Acts动作域,Handlers事件响应域,Bind实例关联值, Info数据域, Statics静态引用]
	Me.UniqueIndex = q.UniqueIndex = vs11.Object.get_UniqueIndex();
	q.Acts = {}; q.Handlers = {}; Me.Bind = q.Bind = {}; q.Info = {}; q.Statics = {};
	//#endregion
}
//#region vs11.Object静态特性
vs11.Object.get_UniqueIndex = function () {
	if (this.lastUniqueIndex == null) this.lastUniqueIndex = 0;
	return this.lastUniqueIndex++;
}
//#endregion
//#endregion
//#region Note便签记录机制
MyClass = vs11.Note = function (args) {
	//#region 类型化,支持受保护的继承变量域
	if (args == null) args = {}; var q = (this.Inheriting) ? args : {}; this.Inheriting = true;
	vs11.Object.apply(this, [q]); var $vs = $vs11, vs = vs11;
	var protected$ = q, Me = public$ = this, v = private$ = {}, base = $vs.copyObject(q);
	//#endregion
	var msgQueue = [];
	var lastMsg = "";
	Me.AppendLine = protected$.AppendLine = function (message) {
		lastMsg = String.format.apply(this, arguments);
		msgQueue.push(lastMsg);
	}
	Me.get_AllMessage = function () {
		return msgQueue;
	}
	Me.get_LastMessage = function () {
		return lastMsg;
	}
}
MyClass.Demo = new MyClass();
vs11.Note.Type = {};
$vs11.sameObject(MyClass.Demo, vs11.Note.Type);
//#endregion
//#region ajax机制[$vs11.ajax.getData,$vs11.ajax.getDataObject]
if (!window.XMLHttpRequest) window.XMLHttpRequest = function () {
	var b = ["Mxsml2.XMLHTTP.3.0", "Msxml2.XMLHTTP"];
	for (var a = 0, c = b.length; a < c; a++) try { return new ActiveXObject(b[a]) } catch (d) { }
	return null
}
$vs11.ajax.xmlHttp = null;
$vs11.ajax.getData = function (path, node) {
	/// <summary>正常返回字符串,取消响应时返回null,出错时返回Number.NaN</summary>
	if ($vs11.designMode) node = vs11.Note.Demo;
	if (xmlHttp == null) xmlHttp = new window.XMLHttpRequest();
	try {
		xmlHttp.open("get", path, false);
		xmlHttp.setRequestHeader('If-Modified-Since', '0');
		xmlHttp.send(null);
	} catch (e) { return null; }
	var status = xmlHttp.status;
	if (status != "200") {
		if (status == 304 || status == 400) {
			if (node) node.AppendLine("当前请求被取消响应,返回状态码:{0}", status);
			return null;
		}
		var errorMsg = path + String.format("\r\nError Number:{0}\r\n========================\r\n", xmlHttp.status) + xmlHttp.responseText;
		if (node) node.AppendLine(errorMsg);
		return Number.NaN;
	}
	if (node) node.AppendLine("请求{0},状态200正常", path);
	var text = xmlHttp.responseText;
	return text;
}
$vs11.ajax.getDataObject = function (jsPath, node) {
	if ($vs11.designMode) node = vs11.Note.Demo;
	var js = $vs11.ajax.getData(jsPath, node);
	try { return window.eval("(" + js + ")"); } catch (e) {
		if (node) node.AppendLine("{0}转换为对象时出错:{1},{2},{3}", e.ErrorNumber, e.Message, e.Description);
		return null;
	}
}
//#endregion
//#region 简单序列化与呈现[$vs11.parser.parserOne,$vs11.parser.view]
$vs11.parser.parserOne = function (obj) {
	var text = "", tag = "", hasProperty = false;
	for (prop in obj) {
		if (typeof (obj[prop]) == "function") continue;
		var value = ("" + obj[prop]).replace("'", "\\'");
		text += tag + prop + "=" +
		    ((obj[prop] == null) ? "null" :
		        ((obj[prop].constructor == Array)
		        ? "['" + value + "']"
		        : "'" + value + "'")
		    );
		tag = "\/";
		hasProperty = true;
	}
	if (hasProperty) {
		text = text.replace(new RegExp(",", "g"), "','"); text = text.replace(new RegExp("\/", "g"), ",");
	} else { text = obj; }
	text = text.replace(new RegExp("<", "g"), "&lt;"); text = text.replace(new RegExp(">", "g"), "&gt;");
	text = "{" + text + "}";
	return text;
}
$vs11.parser.view = function (obj, Document) {
	var div = (Document || document).createElement("DIV");
	div.innerHTML = this.parserOne(obj);
	(Document || document).body.appendChild(div);
}
//#endregion
//#region DOM对象的安全引用,$vs11.pager = document,$vs11.win = window
$vs11.pager = document;
$vs11.win = window;
//#endregion
//*******************控件**************************
//#region UI控件基础类型[vs11.UI.BaseControl,vs11.UI.PageLoader]
//#region vs11.UI.BaseControl
MyClass = vs11.UI.BaseControl = function (args) {
	//#region 类型化,支持受保护的继承变量域
	if (args == null) args = {}; var q = (this.Inheriting) ? args : {}; this.Inheriting = true;
	vs11.Object.apply(this, [q]); var $vs = $vs11, vs = vs11;
	var protected$ = q, Me = public$ = this, v = private$ = {}, base$ = $vs.copyObject(q);
	//#endregion
	//#region 基础分类域[Nodes节点集合,Controls子控件集合]
	Me.Nodes = q.Nodes = {}, q.Controls = {};
	//#endregion
	var nodes = q.Nodes, acts = q.Acts, handlers = q.Handlers, info = q.Info, bind = q.Bind, stt = q.Statics;
	var pager = $vs11.pager, win = $vs11.win, dom = $vs.dom;
	//#region 建立静态方法镜像
	if (stt.vs11_UI_BaseControl !== true) {
		$vs.sameObject(vs11.UI.BaseControl, stt); if ($vs.designMode) stt = vs11.UI.BaseControl;
		stt.vs11_UI_BaseControl = true;
	}
	//#endregion
	//#region 字段 nodes.TopNode info.HTMLNode
	nodes.TopNode = {};
	info.HTMLNode = document.getElementsByTagName("HTML")[0]; if (info.HTMLTopNode == null) info.HTMLTopNode = {};
	var classList = [];
	//#endregion
	//#region 方法 InheritSkin base.Init
	acts.Init = function () { };
	acts.InheritSkin = function (skinHeader) {
		///<summary>对q.Nodes所有节点绑定class，并特意绑定TopNode节点</summary>
		var className; var arr; var header = skinHeader + "_";
		stt.AddClass(nodes.TopNode, skinHeader);
		if ($vs11.designMode) { return; }
		for (var prop in q.Nodes) {
			var node = q.Nodes[prop];
			if (node.nodeType == dom.Node.EnumNodeType.Element) {
				className = prop;
				stt.AddClass(node, header + className);
			}
			if (node.constructor == Array) {
				arr = node;
				for (var i = 0, count = arr.length; i < count; i++) {
					if (arr[i] && arr[i].nodeType == dom.Node.EnumNodeType.Element) {
						className = prop + "_" + i;
						stt.AddClass(arr[i], header + prop);
						stt.AddClass(arr[i], header + className);
					}
				}
			}
		}
		if ($vs11.testMode) { q.$get("vs11_Control_ClassView").innerText += "\r\n/*====*/\r\n" + classList.join("\r\n"); classList = []; }
	}
	//#endregion
}
MyClass.Demo = new MyClass();
//#endregion
//#region vs11.UI.BaseControl静态方法 AddClass SetOpacity GetPointerX GetPointerY GetPosTop GetPosLeft GetHearTop GetHearLeft
MyClass.GetHTMLNode = function () {
	return document.getElementsByTagName("HTML")[0];
}
MyClass.AddClass = function (el, className) {
	///<summary>对指定节点添加class</summary>
	var oldClassName = el.className;
	if (Object.isNullOrEmpty(oldClassName, true) === true)
		el.className = className;
	else if ((" " + oldClassName + " ").indexOf(" " + className + " ") == -1)
		el.className += " " + className;
}
MyClass.SetOpacity = function (el, opacityPercent) {
	if (opacityPercent < 100) {
		el.style.filter = "alpha(opacity=" + opacityPercent + ")"; el.style.opacity = opacityPercent / 100;
	} else {
		el.style.filter = null; el.style.opacity = null;
	}
}
MyClass.GetPointerX = function (event) {
	///<summary>读取当前事件x坐标值</summary>
	return event.pageX || (event.clientX + (document.documentElement.scrollLeft || this.GetHTMLNode().scrollLeft));
}
MyClass.GetPointerY = function (event) {
	///<summary>读取当前事件y坐标值</summary>
	return event.pageY || (event.clientY + (document.documentElement.scrollTop || this.GetHTMLNode().scrollTop));
}
MyClass.GetPosTop = function (node) {
	///<summary>逐级向上，统计某节点的上坐标值</summary>
	var top = 0, nextParent = node;
	if (node.style && node.style.position == 'absolute' && ('' + node.style.topcenter) == 'true') {
		node.style.display = "inline-block";
		var centerTop = ((this.GetHTMLNode().offsetHeight - node.offsetHeight) / 2)
		+ (document.documentElement.scrollTop || this.GetHTMLNode().scrollTop);
		centerTop = centerTop < 0 ? 0 : centerTop;
		node.style.top = centerTop + "px";
		node.style.topcenter = 'keep';
		node.style.display = "none";
	}
	while (nextParent != null) {
		if (nextParent.style && nextParent.style.position == 'absolute' && !isNaN(parseInt(nextParent.style.top))) {
			top += parseInt(nextParent.style.top); break;
		}
		top += isNaN(nextParent.offsetTop) ? 0 : nextParent.offsetTop;
		nextParent = nextParent.parentNode;
	}
	return top;
}
MyClass.GetPosLeft = function (node) {
	///<summary>逐级向上，统计某节点的左坐标值</summary>
	var left = 0, nextParent = node;
	if (node.style && node.style.position == 'absolute' && ('' + node.style.leftcenter) == 'true') {
		node.style.display = "inline-block";
		var centerLeft = ((this.GetHTMLNode().offsetWidth - node.offsetWidth) / 2)
		+ (document.documentElement.scrollLeft || this.GetHTMLNode().scrollLeft);
		node.style.left = centerLeft + "px";
		node.style.leftcenter = 'keep'
		node.style.display = "none";
	}
	while (nextParent != null) {
		if (nextParent.style && nextParent.style.position == 'absolute' && !isNaN(parseInt(nextParent.style.left))) {
			left += parseInt(nextParent.style.left); break;
		}
		left += isNaN(nextParent.offsetLeft) ? 0 : nextParent.offsetLeft;
		nextParent = nextParent.parentNode;
	}
	return left;
}
MyClass.GetHearTop = function (node) { var v = parseInt(node.style.marginTop); return isNaN(v) ? 0 : v; }
MyClass.GetHearLeft = function (node) { var v = parseInt(node.style.marginLeft); return isNaN(v) ? 0 : v; }
//#endregion
//#region 页面装载器 vs11.UI.PageLoader
MyClass = vs11.UI.PageLoader = function (args) {
	//#region 类型化,支持受保护的继承变量域
	if (args == null) args = {}; var q = (this.Inheriting) ? args : {}; this.Inheriting = true;
	vs11.Object.apply(this, [q]); var $vs = $vs11, vs = vs11;
	var protected$ = q, Me = public$ = this, v = private$ = {}, base$ = $vs.copyObject(q);
	//#endregion
	var acts = q.Acts;
	if (q.Page_Load == null) q.Page_Load = function () { alert(4); }
	$vs.loadOnce(q["Page_Load"]);
}
//#endregion
//#endregion
//#region 有代码提示的DOM操作封装
if (!$vs11.designMode) with ($vs11) {
	dom.A = dom.Button = dom.CheckInput = dom.Div = dom.Fieldset = dom.Form = dom.Iframe = dom.Image = dom.ImageInput
    = dom.Input = dom.Label = dom.Legend = dom.Marquee = dom.Node = dom.Option = dom.P = dom.Pre = dom.Select
    = dom.Span = dom.Style = dom.Table = dom.TBody = dom.TD = dom.Textarea = dom.TFoot = dom.THead = dom.TR = { style: {},
    	EnumAlign: { center: "center", justify: "justify", left: "left", right: "right", Default: "left" },
    	EnumNodeType: { Element: 1, Text: 3 },
    	EnumReadyState: { Uninitialized: "uninitialized", Loading: "loading"
            , Loaded: "loaded", Interactive: "interactive", Complete: "complete"
    	},
    	EnumTarget: { Blank: "_blank", Self: "_self", Parent: "_parent", Default: "" },
    	EnumApplyElementPosition: { Outside: "outside", Inside: "inside" }
    };
	dom.DoNothingHref = "javascript:void(0);";
	dom.BlankText = "&nbsp;";
	dom.Space = function (n) { var s = []; for (var i = 0; i < n; i++) s.push(dom.BlankText); return s.join(""); }
	dom.Events = ["onabort", "onafterprint", "onafterupdate", "onbeforecopy", "onbeforecut", "onbeforeeditfocus"
    , "onbeforepaste", "onbeforeprint", "onbeforeunload", "onbeforeupdate", "onblur", "onbounce"
    , "oncellchange", "onchange", "onclick", "oncontextmenu", "oncopy", "oncut"
    , "ondataavailable", "ondatasetchanged", "ondatasetcomplete", "ondblclick", "ondrag", "ondragend"
    , "ondragenter", "ondragleave", "ondragover", "ondragstart", "ondrop", "onerror"
    , "onerrorupdate", "onfilterchange", "onfinish", "onfocus", "onhelp", "onkeydown"
    , "onkeypress", "onkeyup", "onload", "onlosecapture", "onmousedown", "onmousemove"
    , "onmouseout", "onmouseover", "onmouseup", "onpaste", "onpropertychange", "onreadystatechange"
    , "onreset", "onresize", "onrowenter", "onrowexit", "onrowsdelete", "onrowsinserted"
    , "onscroll", "onselect", "onselectstart", "onstart", "onstop", "onsubmit", "onunload"]
	for (var domEventIndex = 0, domEventCount = dom.Events.length; domEventIndex < domEventCount; domEventIndex++) {
		var eventName = dom.Events[domEventIndex]; dom.Events[eventName] = eventName.substring(2);
	}
}
with ($vs11) {
	doc.$get = function (id) { return document.getElementById(id); }
	with (doc) {
		doc.GetNode = doc.GetDiv = doc.GetFieldSet = doc.GetLegend
         = doc.GetP = doc.GetPre = doc.GetSpan = function (id) {
         	return $vs11.designMode ? dom.Node : $get(id);
         }
		doc.GetA = doc.GetALink = function (id) {
			return $vs11.designMode ? dom.A : $get(id);
		}
		doc.GetForm = function (id) {
			return $vs11.designMode ? dom.Form : $get(id);
		}
		doc.GetIframe = function (id) {
			return $vs11.designMode ? dom.Iframe : $get(id);
		}
		doc.GetImage = function (id) {
			return $vs11.designMode ? dom.Image : $get(id);
		}
		doc.GetMarquee = function (id) {
			return $vs11.designMode ? dom.Marquee : $get(id);
		}
		doc.GetOption = function (id) {
			return $vs11.designMode ? dom.Option : $get(id);
		}
		doc.GetSelect = function (id) {
			return $vs11.designMode ? dom.Select : $get(id);
		}
		doc.GetTable = function (id) {
			return $vs11.designMode ? dom.Table : $get(id);
		}
		doc.GetTBody = function (id) {
			return $vs11.designMode ? dom.Table : $get(id);
		}
		doc.GetTR = function (id) {
			return $vs11.designMode ? dom.TR : $get(id);
		}
		doc.GetTD = function (id) {
			return $vs11.designMode ? dom.TD : $get(id);
		}
		doc.GetButton = function (id) {
			return $vs11.designMode ? dom.Button : $get(id);
		}
		doc.GetLabel = function (id) {
			return $vs11.designMode ? dom.Label : $get(id);
		}
		doc.GetCheckBoxInput = doc.GetRadioInput = doc.GetCheckInput = function (id) {
			return $vs11.designMode ? dom.CheckInput : $get(id);
		}
		doc.GetFileInput = function (id) {
			return $vs11.designMode ? dom.Input : $get(id);
		}
		doc.GetHiddenInput = doc.GetInput = doc.GetPasswordInput = doc.GetResetInput
         = doc.GetSubmitInput = doc.GetTextInput = function (id) {
         	return $vs11.designMode ? dom.Input : $get(id);
         }
		doc.GetImageInput = function (id) {
			return $vs11.designMode ? dom.ImageInput : $get(id);
		}
	}
}

with ($vs11) {
	dom.Blank = "&nbsp;";
	dom.NewA = dom.NewALink = function (href, target, innerHTML, isInlineBlock) {
		var link = $vs11.pager.createElement("A");
		if ($vs11.designMode) link = dom.A;
		link.href = Object.isNullOrEmpty(href, "javascript:void(0)");
		link.target = Object.isNull(target, "");
		link.innerHTML = Object.isNull(innerHTML, "");
		if (isInlineBlock == true) link.style.display = "inline-block";
		return link;
	}
	dom.NewDiv = function (innerHTML) {
		var div = $vs11.pager.createElement("DIV");
		if ($vs11.designMode) div = dom.Div;
		div.innerHTML = Object.isNull(innerHTML, "");
		return div;
	}
	dom.NewFieldset = function (title) {
		var fieldset = $vs11.pager.createElement("FIELDSET");
		if ($vs11.designMode) fieldset = dom.Fieldset;
		if (title != null) {
			var legend = document.createElement("LEGEND");
			legend.innerHTML = title;
			fieldset.appendChild(legend);
		}
		return fieldset;
	}
	dom.NewForm = function (action, method, formEncoding) {
		var form = $vs11.pager.createElement("FORM");
		if ($vs11.designMode) form = dom.Form;
		form.action = Object.isNull(action, "");
		form.method = Object.isNullOrEmpty(method, dom.Form.EnumMethod.Get);
		form.encoding = Object.isNull(formEncoding, dom.Form.EnumFormEncoding.Default);
		return form;
	}
	dom.BlankUrl = "about:blank";
	dom.NewIframe = function (src, name) {
		name = Object.isNullOrEmpty(name, "");
		var iframe = null;
		if ($vs11.browser.isIE) {
			try { iframe = $vs11.pager.createElement(String.format("<iframe id='{0}' name='{0}'></iframe>", name)); } catch (e) { }
		}
		if (iframe == null) {
			iframe = $vs11.pager.createElement("IFRAME");
		}
		if ($vs11.designMode) iframe = dom.Iframe;
		if (src != null) iframe.src = src;
		iframe.id = name;
		iframe.name = name;
		return iframe;
	}
	dom.NewImage = dom.NewImg = function (src) {
		var image = new Image();
		if ($vs11.designMode) image = dom.Image;
		if (src != null) {
			image.src = src;
		}
		return image;
	}
	dom.NewLegend = function (title) {
		var legend = $vs11.pager.createElement("LEGEND");
		if ($vs11.designMode) legend = dom.Legend;
		legend.innerHTML = Object.isNullOrEmpty(title, "");
		return legend;
	}
	dom.NewMarquee = function () {
		var marquee = $vs11.pager.createElement("Marquee");
		if ($vs11.designMode) marquee = dom.Marquee;
		return marquee;
	}
	dom.NewOption = function (text, value) {
		var option = $vs11.pager.createElement("option");
		if ($vs11.designMode) option = dom.Option;
		option.text = text;
		option.value = Object.isNull(value, text);
		return option;
	}
	dom.NewP = function (innerHTML) {
		var p = $vs11.pager.createElement("P");
		if ($vs11.designMode) p = dom.P;
		p.innerHTML = Object.isNull(innerHTML, "");
		return p;
	}
	dom.NewPre = function (innerHTML) {
		var pre = $vs11.pager.createElement("PRE");
		if ($vs11.designMode) pre = dom.Pre;
		pre.innerHTML = Object.isNull(innerHTML, "");
		return pre;
	}
	dom.NewSelect = function (isMulti) {
		var select = $vs11.pager.createElement("SELECT");
		if ($vs11.designMode) select = dom.Select;
		select.multiple = isMulti;
		return select;
	}
	dom.NewSpan = function (innerHTML, isInlineBlock) {
		var span = $vs11.pager.createElement("SPAN");
		if ($vs11.designMode) span = dom.Span;
		if (isInlineBlock == true) span.style.display = "inline-block";
		span.innerHTML = Object.isNull(innerHTML, "");
		return span;
	}
	dom.NewUL = function () {
		var ul = $vs11.pager.createElement("UL");
		if ($vs11.designMode) ul = dom.UL;
		return ul;
	}
	dom.NewOL = function () {
		var ol = $vs11.pager.createElement("OL");
		if ($vs11.designMode) ol = dom.OL;
		return ol;
	}
	dom.NewLI = function (innerHTML) {
		var li = $vs11.pager.createElement("LI");
		if ($vs11.designMode) li = dom.LI;
		li.innerHTML = Object.isNull(innerHTML, "");
		return li;
	}
	dom.NewTable = function () {
		var table = $vs11.pager.createElement("table");
		if ($vs11.designMode) table = dom.Table;
		table.border = 0;
		table.cellPadding = 0;
		table.cellSpacing = 0;
		return table;
	}
	dom.NewTBody = function (table) {
		var tbody = $vs11.pager.createElement("TBody");
		if ($vs11.designMode) tbody = dom.TBody;
		if (table) table.appendChild(tbody);
		return tbody;
	}
	dom.NewTHead = function (table) {
		var thead = $vs11.pager.createElement("THead");
		if ($vs11.designMode) thead = dom.THead;
		if (table) table.appendChild(thead);
		return thead;
	}
	dom.NewTFoot = function (table) {
		var tfoot = $vs11.pager.createElement("TFoot");
		if ($vs11.designMode) tfoot = dom.TFoot;
		if (table) table.appendChild(tfoot);
		return tfoot;
	}
	dom.NewTR = dom.NewRowOfTable = function (tableOrTBody, rowIndex) {
		if ($vs11.designMode) tableOrTBody = dom.TBody;
		var tr = tableOrTBody.insertRow(Object.isNull(rowIndex, -1));
		return tr;
	}
	dom.NewTD = dom.NewCellOfTable = function (tr, cellIndex, text) {
		if ($vs11.designMode) tr = dom.TR;
		var td = tr.insertCell(Object.isNull(cellIndex, -1));
		td.innerHTML = Object.isNull(text, "");
		return td;
	}
	dom.NewButton = function (innerHTML) {
		var button = $vs11.pager.createElement("Button");
		if ($vs11.designMode) button = dom.Button;
		button.innerHTML = Object.isNull(innerHTML, "");
		return button;
	}
	dom.NewLabel = function (text, htmlFor) {
		var label = $vs11.pager.createElement("Label");
		if ($vs11.designMode) label = dom.Label;
		label.innerHTML = text;
		label.htmlFor = htmlFor;
		return label;
	}
	dom.NewCheckBoxInput = function (name, value) {
		var checkbox = null;
		if ($vs11.browser.isIE) {
			try{checkbox = $vs11.pager.createElement(String.format("<input type='checkbox' name='{0}' />", name));}catch(e){}
		} 
		if(checkbox == null) {
			checkbox = $vs11.pager.createElement("input");
			checkbox.type = "checkbox";
			checkbox.name = name;
		}
		if ($vs11.designMode) checkbox = dom.CheckInput;
		checkbox.value = Object.isNull(value, "");
		checkbox.id = "radio_" + (vs11.Object.get_UniqueIndex());
		return checkbox;
	}
	dom.NewRadioInput = function (name, value) {
		var radio = null;
		if ($vs11.browser.isIE) {
			try{radio = $vs11.pager.createElement(String.format("<input type='radio' name='{0}' />", name));}catch(e){}
		} 
		if(radio == null) {
			radio = document.createElement("input");
			radio.type = "radio";
			radio.name = name;
		}
		if ($vs11.designMode) radio = dom.CheckInput;
		radio.value = Object.isNull(value, "");
		radio.id = "radio_" + (vs11.Object.get_UniqueIndex());
		return radio;
	}
	dom.NewFileInput = function (idAndname, value) {
		var input = null;
		if ($vs11.browser.isIE) {
			try{input = $vs11.pager.createElement(String.format("<input type='file' id='{0}' name='{0}' />", idAndname));}catch(e){}
		} 
		if(input == null) {
			input = $vs11.pager.createElement("input");
			input.type = "file";
			input.name = idAndname;
			input.id = idAndname;
		}
		if ($vs11.designMode) input = dom.Input;
		input.value = Object.isNull(value, "");
		return input;
	}
	dom.NewHiddenInput = function (idAndname, value) {
		var input = null;
		if ($vs11.browser.isIE) {
			try{input = $vs11.pager.createElement(String.format("<input type='hidden' id='{0}' name='{0}' />", idAndname));}catch(e){}
		} 
		if(input == null) {
			input = $vs11.pager.createElement("input");
			input.type = "hidden";
			input.name = idAndname;
			input.id = idAndname;
		}
		if ($vs11.designMode) input = dom.Input;
		input.value = Object.isNull(value, "");
		return input;
	}
	dom.NewImageInput = function (idAndname, value, src) {
		var image = null;
		if ($vs11.browser.isIE) {
			try{image = $vs11.pager.createElement(String.format("<input type='image' id='{0}' name='{0}' />", idAndname));}catch(e){}
		} 
		if(image == null) {
			image = $vs11.pager.createElement("input");
			image.type = "image";
			image.name = idAndname;
			image.id = idAndname;
		}
		if ($vs11.designMode) image = dom.ImageInput;
		image.value = Object.isNull(value, "");
		image.src = src;
		return image;
	}
	dom.NewPasswordInput = function (idAndname, value) {
		var input = null;
		if ($vs11.browser.isIE) {
			try{input = $vs11.pager.createElement(String.format("<input type='password' id='{0}' name='{0}' />", idAndname));}catch(e){}
		} 
		if(input == null) {
			input = $vs11.pager.createElement("input");
			input.type = "password";
			input.name = idAndname;
			input.id = idAndname;
		}
		if ($vs11.designMode) input = dom.Input;
		input.value = Object.isNull(value, "");
		return input;
	}
	dom.NewResetInput = function (idAndname, value) {
		var input = null;
		if ($vs11.browser.isIE) {
			try{input = $vs11.pager.createElement(String.format("<input type='reset' id='{0}' name='{0}' />", idAndname));}catch(e){}
		} 
		if(input == null) {
			input = $vs11.pager.createElement("input");
			input.type = "reset";
			input.name = idAndname;
			input.id = idAndname;
		}
		if ($vs11.designMode) input = dom.Input;
		input.value = Object.isNull(value, "");
		return input;
	}
	dom.NewSubmitInput = function (idAndname, value) {
		var input = null;
		if ($vs11.browser.isIE) {
			try{input = $vs11.pager.createElement(String.format("<input type='submit' id='{0}' name='{0}' />", idAndname));}catch(e){}
		} 
		if(input == null) {
			input = document.createElement("input");
			input.type = "submit";
			input.name = idAndname;
			input.id = idAndname;
		}
		if ($vs11.designMode) input = dom.Input;
		input.value = Object.isNull(value, "");
		return input;
	}
	dom.NewTextInput = function (idAndname, value) {
		var input = null;
		if ($vs11.browser.isIE) {
			try{input = $vs11.pager.createElement(String.format("<input type='text' id='{0}' name='{0}' />", idAndname));}catch(e){}
		} 
		if(input == null) {
			input = $vs11.pager.createElement("input");
			input.type = "text";
			input.name = idAndname;
			input.id = idAndname;
		}
		if ($vs11.designMode) input = dom.Input;
		input.value = Object.isNull(value, "");
		return input;
	}
	dom.NewTextarea = function (idAndname, value) {
		var textarea;
		textarea = $vs11.pager.createElement("textarea");
		if ($vs11.designMode) textarea = dom.Textarea;
		textarea.name = idAndname;
		textarea.id = idAndname;
		textarea.value = Object.isNull(value, "");
		return textarea;
	}
}
//#endregion
//#region vs11.UI.Layer 浮动层 仅继承依赖vs11.UI.BaseControl
MyClass = vs11.UI.Layer = function (args) {
    ///<summary>args={TopNode:Node,IsModal:true|false,FromHear:true|false}</summary>
    //#region 类型化,支持受保护的继承变量域
    if (args == null) args = {}; var q = (this.Inheriting) ? args : {}; this.Inheriting = true;
    vs11.UI.BaseControl.apply(this, [q]); var $vs = $vs11, vs = vs11;
    var protected$ = q, Me = public$ = this, v = private$ = {}//, base$ = $vs.copyObject(q);
    var info = q.Info, nodes = q.Nodes, acts = q.Acts, handlers = q.Handlers;
    var baseControlClass = vs11.UI.BaseControl, stt = vs11.UI.Layer.Private_vs_UI_Layer;
    var enums = q.Enums = Me.Enums = {};
    designMode = $vs11.designMode;
    //#endregion
    //#region 构造函数参数析取
    if (args != null) {
        var isModal = args.IsModal, topNode = args.TopNode, fromHear = args.FromHear;
        isModal = isModal == true ? true : false;
        fromHear = fromHear == true ? true : false;
    }
    //#endregion
    //#region 基础数据定义
    enums.EnumWindowState = { Hidden: 0, Mined: 4, Opened: 8, Maxed: 16 }
    //#endregion
    //#region 准备事件ToStartMove
    //$vs.addEvent(Me, "ToStartMove");
    //#endregion
    //#region 状态器
    info.Draging = false; //是否正在移动
    info.IsModal = false; //是否模态
    info.ZIndex = -1; 	//当前Z轴位置

    info.LastPos = { Left: 0, Top: 0, OffsetWidth: 0, OffsetHeight: 0, Width: 0, Height: 0 };
    info.LastMoveHandlerNode = dom.Node;
    info.DragPos = { x: -1, y: -1 };
    info.BackPos = { x: -1, y: -1 };
    info.KeepModalViewTimer = null;
    //#endregion
    //#region 主要关联dom节点
    nodes.TopNode = dom.Node;
    nodes.ModalLayer = dom.Node;
    nodes.ModalFrame = dom.Iframe;
    nodes.CoverFrame = dom.Iframe;
    nodes.ViewStateHidden = dom.Input;
    //#endregion
    //#region 初始化
    var baseInit = acts.Init;
    Me.Init = acts.Init = function (isModal, topNode, fromHear) {
        /// <summary>完成层元素的初始构造,确定层的基础特性,注意:这些特性后续不可改变</summary>
        /// <param name="isModal" type="Boolean">是否构造为模态窗</param>
        /// <param name="fromHear" type="Boolean">是否为相对于流布局的相对定位,即使用margin定位</param>
        delete (Me.Init); //只初始化一次
        if ($vs.pager.body == null) return;
        if ($vs11.designMode) { return; }
        if (info.ZIndex == -1) info.ZIndex = stt.NewLayer(Me);
        baseInit();
        info.IsModal = (isModal === true) ? true : false;
        nodes.TopNode = topNode || dom.NewSpan("", true); //未指定顶部容器节点,则创建之
        if (topNode && topNode.IsLayered === true) return;
        if (topNode) topNode.IsLayered = true;
        var v = info.ViewState;
        if (info.IsModal) {	//准备模态窗所需的div和遮罩iframe
            nodes.ModalFrame = dom.NewIframe(dom.BlankUrl, "t");
            nodes.ModalLayer = dom.NewDiv();
            with (nodes.ModalFrame.style) { position="absolute"; width="100%"; height="100%"; zIndex="-1";}
            with (nodes.ModalLayer.style) { position="absolute"; width="100%"; height="100%"; left="0px"; top="0px"; backgroundColor="White";}
            document.body.appendChild(nodes.ModalLayer);
            nodes.ModalLayer.appendChild(nodes.ModalFrame);
        }
        nodes.CoverFrame = dom.NewIframe();
        with (nodes.CoverFrame.style) { position="absolute"; width="20px"; height="234px"; zIndex="-1"; left="0px"; top="0px"; }
        if (!topNode) document.body.appendChild(nodes.TopNode);
        topNodeStyle = nodes.TopNode.style;
        if (fromHear) {//支持margin-left,margin-top的相对浮动定位
            nodes.TopNode.FromHear = true;
            topNodeStyle.position = "absolute";
            v.Left = topNodeStyle.marginLeft = topNode ? baseControlClass.GetHearLeft(topNode) : 0;
            v.Top = topNodeStyle.marginTop = topNode ? baseControlClass.GetHearTop(topNode) : 0;
        } else {	//支持left,top的绝对浮动定位
            nodes.TopNode.FromHear = false;
            var forms = document.getElementsByTagName("form");
            if (topNode.offsetWidth == 0 && forms.length > 0) forms[0].appendChild(nodes.TopNode);
            if (topNode.style.display != "none") {
                v.Left = topNodeStyle.left = topNode ? baseControlClass.GetPosLeft(topNode) : 0;
                v.Top = topNodeStyle.top = topNode ? baseControlClass.GetPosTop(topNode) : 0;
            }
        }
        nodes.TopNode.appendChild(nodes.CoverFrame);
        acts.InitLayerView();
        window.setTimeout(acts.ReloadLayerSize, 100);

        acts.InitModalState();
        acts.InheritSkin("vs11_UI_Layer");
        AttachEvent();
    }
    //#endregion
    //#region 属性器ZIndex,IsShow
    Me.get_ZIndex = acts.get_ZIndex = function () {
        return info.ZIndex;
    }
    Me.set_ZIndex = acts.set_ZIndex = function (zIndex) {
        info.ZIndex = zIndex;
        nodes.TopNode.style.zIndex = zIndex + 2;
        nodes.ModalLayer.style.zIndex = zIndex;
    }
    Me.get_IsShow = acts.get_IsShow = function () {
        return (nodes.TopNode.style.display == "block");
    }
    //#endregion
    //#region 层状态的初始化和维持
    acts.InitLayerView = function () {
        /// <summary>初始化层的基本数据</summary>
        with (nodes.TopNode.style) {
            zIndex = info.ZIndex + 2;
        }
        with (nodes.CoverFrame) {
            frameBorder = 0;
            with (style) {
                width = nodes.TopNode.offsetWidth + "px";
                //filter = "alpha(opacity=1)";
                //opacity = 0.01;
                height = nodes.TopNode.offsetHeight + "px";
            }
        }
    }
    Me.ReloadLayerSize = acts.ReloadLayerSize = function () {
        /// <summary>根据当前层的显示大小调整遮罩层的大小</summary>
        with (nodes.CoverFrame) {
            with (style) {
                width = nodes.TopNode.offsetWidth + "px";
                height = nodes.TopNode.offsetHeight + "px";
            }
        }
    }
    acts.InitModalState = function () {
        /// <summary>初始化模态窗口所需遮罩元素的必要属性</summary>
        with (nodes.ModalLayer.style) {
            zIndex = info.ZIndex;
            //filter = "alpha(opacity=70)";
            //opacity = 0.7;
            display = "none";
        }
        with (nodes.ModalFrame) {
            frameBorder = 0;
        }
    }
    acts.KeepModalView = function () {
        /// <summary>根据当前呈现状态,调整模态遮罩层的显示状态</summary>
        if (nodes.TopNode.offsetHeight == 0) {
            nodes.ModalLayer.style.display = "none";
            window.clearInterval(info.KeepModalViewTimer);
        }
    }
    //#endregion
    //#region 窗口视图状态保持器
    info.ViewState = { WindowState: 0, Left: 0, Top: 0, IsNoPos: false }
    acts.SaveViewState = function () {
        var v = info.ViewState;
        var topNode = nodes.TopNode, topNodeStyle = topNode.style;
        if (topNode.FromHear) {
            v.Left = baseControlClass.GetHearLeft(topNode); v.Top = baseControlClass.GetHearTop(topNode);
        } else {
            v.Left = baseControlClass.GetPosLeft(topNode); v.Top = baseControlClass.GetPosTop(topNode);
        }
        nodes.ViewStateHidden.value = String.format("{0}|{1}|{2}", v.WindowState, v.Left, v.Top);
    }
    //#endregion
    //#region 拖动支持
    acts.ReturnFalse = function () { if(info.Draging) return false; }
    handlers.StartMove = function (event) {
        //if (!Me.ToStartMove(Me)) return;
        var me = info.LastMoveHandlerNode = this; if (designMode) me = dom.Node;
        me.style.cursor = "move";
        nodes.TopNode.style.position = "absolute";
        info.Draging = true;
        $vs11.addHandler(document, "mousemove", handlers.Moving);
        $vs11.addHandler(document, "mouseup", handlers.StopMove);
        $vs11.addHandler(nodes.TopNode, "selectstart", acts.ReturnFalse);
        var mouseX = stt.GetPointerX(event);
        var mouseY = stt.GetPointerY(event);
        var leftMe = topMe = 0;
        var topNode = nodes.TopNode;
        if (topNode.FromHear) { leftMe = baseControlClass.GetHearLeft(topNode); topMe = baseControlClass.GetHearTop(topNode); }
        else { leftMe = baseControlClass.GetPosLeft(topNode); topMe = baseControlClass.GetPosTop(topNode); }
        with (info.DragPos) {
            x = mouseX;
            y = mouseY;
        }
        with (info.BackPos) {
            x = leftMe;
            y = topMe;
        }
    }
    handlers.Moving = function (event) {
        if (!info.Draging) return;
        if (info.IsModal) {
            nodes.ModalLayer.style.display = "none";
        }
        var posX = stt.GetPointerX(event);
        var posY = stt.GetPointerY(event);
        var leftMe = topMe = 0;
        var topNode = nodes.TopNode;
        if (topNode.FromHear) {
            leftMe = baseControlClass.GetHearLeft(topNode); topMe = baseControlClass.GetHearTop(topNode);
        } else {
            leftMe = baseControlClass.GetPosLeft(topNode); topMe = baseControlClass.GetPosTop(topNode);
        }
        var posNowX = posX - info.DragPos.x + leftMe;
        var posNowY = posY - info.DragPos.y + topMe;

        var topNodeStyle = topNode.style;
        if (topNode.FromHear) { topNodeStyle.marginLeft = posNowX + "px"; topNodeStyle.marginTop = posNowY + "px"; }
        else { topNodeStyle.left = posNowX + "px"; topNodeStyle.top = posNowY + "px"; }
        info.DragPos.x = posX;
        info.DragPos.y = posY;
    }
    handlers.StopMove = function (event) {
        if (!info.Draging) return;
        if (info.IsModal) {
            nodes.ModalLayer.style.display = "block";
            window.clearInterval(info.KeepModalViewTimer);
            info.KeepModalViewTimer = window.setInterval(acts.KeepModalView, 200);
        }
        var topNode = nodes.TopNode, topNodeStyle = topNode.style;
        var me = info.LastMoveHandlerNode;
        me.style.cursor = "default";
        info.Draging = false;
        $vs11.removeHandler(document, "mousemove", handlers.Moving);
        $vs11.removeHandler(document, "mouseup", handlers.StopMove);
        $vs11.removeHandler(nodes.TopNode, "selectstart", acts.ReturnFalse);
        var mouseX = stt.GetPointerX(event) - (document.documentElement.scrollLeft || document.body.scrollLeft);
        var mouseY = stt.GetPointerY(event) - (document.documentElement.scrollTop || document.body.scrollTop);
        var htmlOffsetHeight = document.getElementsByTagName("HTML")[0].offsetHeight;
        var bodyHeight = document.body.clientHeight;
        var maxHeight = htmlOffsetHeight > bodyHeight ? htmlOffsetHeight : bodyHeight;
        if (mouseX < 1 || mouseY < 1 || mouseX > document.body.clientWidth || mouseY > maxHeight) {
            if (topNode.FromHear) { topNodeStyle.marginLeft = info.BackPos.x + "px"; topNodeStyle.marginTop = info.BackPos.y + "px"; }
            else { topNodeStyle.left = info.BackPos.x + "px"; topNodeStyle.top = info.BackPos.y + "px"; }
        };
        with (info.LastPos) {
            if (topNode.FromHear) { Left = baseControlClass.GetHearLeft(topNode); Top = baseControlClass.GetHearTop(topNode); }
            else { Left = baseControlClass.GetPosLeft(topNode); Top = baseControlClass.GetPosTop(topNode); }
            OffsetWidth = parseInt(topNode.offsetWidth);
            OffsetHeight = parseInt(topNode.offsetHeight);
        }
        acts.SaveViewState();
    }
    Me.BindMoveHandler = acts.BindMoveHandler = function (node) {
        $vs11.addHandler(node, "mousedown", handlers.StartMove);
        node.style.cursor = "default";
    }
    //#endregion
    //#region 显隐控制
    acts.ViewTop = function () {
        acts.ReloadLayerSize();
        stt.ToActiveLayer(Me);
    }
    Me.ShowAt = acts.ShowAt = function (left, top) {
        var topNode = nodes.TopNode, topNodeStyle = topNode.style;
        var oldDisplay = nodes.TopNode.style.OldDisplay;
        nodes.TopNode.style.display = oldDisplay ? oldDisplay : "block";
        if (topNode.FromHear) { topNodeStyle.marginLeft = left + "px"; topNodeStyle.marginTop = top + "px"; }
        else { topNodeStyle.left = left + "px"; topNodeStyle.top = top + "px"; }
        info.ViewState.WindowState = enums.EnumWindowState.Opened;
        acts.SaveViewState();
        with (info.ShowFilterRecord) { cOpacity = 10, toOpacity = 100; }
        acts.ShowFilter();
        acts.ViewTop();
    }
    Me.Hidden = Me.Close = acts.Hidden = acts.Close = function () {
        if (nodes.TopNode.style.display != "none") { nodes.TopNode.style.OldDisplay = nodes.TopNode.style.display; }
        nodes.TopNode.style.display = "none";
        nodes.ModalLayer.style.display = "none";
        info.ViewState.WindowState = enums.EnumWindowState.Hidden;
        acts.SaveViewState();
    }
    info.ShowFilterRecord = { cOpacity: 0, toOpacity: 0 }
    info.ShowFilterTimer = null;
    acts.ShowFilter = function () {
        window.clearTimeout(info.ShowFilterTimer);
        stt.SetOpacity(nodes.TopNode, info.ShowFilterRecord.cOpacity);
        if (info.ShowFilterRecord.cOpacity < info.ShowFilterRecord.toOpacity) {
            with (info.ShowFilterRecord) { cOpacity = (cOpacity + 20) > toOpacity ? toOpacity : (cOpacity + 20); }
            info.ShowFilterTimer = window.setTimeout(acts.ShowFilter, 30);
        }
    }
    Me.ShowCenter = acts.ShowCenter = function () {
        if (!nodes.TopNode.FromHear) {
            nodes.TopNode.style.topcenter = "true";
            nodes.TopNode.style.leftcenter = "true";

            nodes.TopNode.style.left = acts.GetPosLeft(nodes.TopNode);
            nodes.TopNode.style.top = acts.GetPosTop(nodes.TopNode);
        }
        acts.Show();
    }
    Me.Show = acts.Show = function () {
        with (info.ShowFilterRecord) { cOpacity = 10, toOpacity = 100; }
        var oldDisplay = nodes.TopNode.style.OldDisplay;
        var v = info.ViewState;
        if (!nodes.TopNode.FromHear && v.IsNoPos) {
            v.Left = nodes.TopNode.style.marginLeft = acts.GetHearLeft(nodes.TopNode);
            v.Top = nodes.TopNode.style.marginTop = acts.GetHearTop(nodes.TopNode);
        }
        stt.SetOpacity(nodes.TopNode, info.ShowFilterRecord.cOpacity);
        info.ViewState.WindowState = enums.EnumWindowState.Opened;
        acts.SaveViewState();
        acts.ShowFilter();
        nodes.TopNode.style.display = oldDisplay ? oldDisplay : "block";
        if (info.IsModal) {
            nodes.ModalLayer.style.display = "block";
            window.clearInterval(info.KeepModalViewTimer);
            info.KeepModalViewTimer = window.setInterval(acts.KeepModalView, 200);
        }
        acts.ViewTop();
    }
    //#endregion
    //#region 视图状态保持
    acts.ReadViewState = function () {
        var arr = nodes.ViewStateHidden.value.split("|");
        var v = info.ViewState;
        v.WindowState = isNaN(parseInt(arr[0])) ? enums.EnumWindowState.Hidden : parseInt(arr[0]);
        if (arr.length >= 3) {
            v.IsNoPos = false;
            v.Left = isNaN(parseInt(arr[1])) ? 0 : parseInt(arr[1]);
            v.Top = isNaN(parseInt(arr[2])) ? 0 : parseInt(arr[2]);
            var topNode = nodes.TopNode, topNodeStyle = topNode.style;
            if (topNode.FromHear) { topNodeStyle.marginLeft = v.Left + "px"; topNodeStyle.marginTop = v.Top + "px"; }
            else { topNodeStyle.left = v.Left + "px"; topNodeStyle.top = v.Top + "px"; }
        } else { v.IsNoPos = true; }
    }
    Me.BindViewState = acts.BindViewState = function (viewStateHiddenNode) {
        nodes.ViewStateHidden = viewStateHiddenNode;
        acts.ReadViewState();
        acts.SaveViewState();
        return info.ViewState.WindowState;
    }
    Me.LoadViewState = acts.LoadViewState = function () {
        acts.ReadViewState();
        nodes.TopNode.style.visibility = "visible";
        var v = info.ViewState;
        switch (v.WindowState) {
            case enums.EnumWindowState.Opened:
                acts.Show();
                break;
            case enums.EnumWindowState.Hidden:
                acts.Close();
                break;
            case enums.EnumWindowState.Mined:
                //todo
                acts.Show();
                break;
            case enums.EnumWindowState.Maxed:
                //todo
                acts.Show();
                break;
        }
        var topNode = nodes.TopNode, topNodeStyle = topNode.style;
        if (topNode.FromHear) { topNodeStyle.marginLeft = v.Left + "px"; topNodeStyle.marginTop = v.Top + "px"; }
        else { topNodeStyle.left = v.Left + "px"; topNodeStyle.top = v.Top + "px"; }
    }
    //#endregion
    //#region 销毁处理
    var baseDestroy = q.Destroy;
    q.Destroy = function () {
        stt.DeleteLayer(Me);
        if (info.IsModal) {
            nodes.ModalLayer.removeNode(true);
        }
        baseDestroy();
    }
    //#endregion
    //#region 预绑定事件
    var AttachEvent = function () {
        if ($vs11.designMode) { return; }
        $vs.addHandler(nodes.TopNode, dom.Events.onmousedown, acts.ViewTop);
    }
    //#endregion
    //#region 公开绑定
    Me.BindCloseButton = acts.BindCloseButton = function (closeButton) {
        if (closeButton) $vs.addHandler(closeButton, dom.Events.onclick, acts.Close)
    }
    //#endregion
    if (args) acts.Init(isModal, topNode, fromHear);
}
//#endregion
//#region vs11.UI.Layer.Private_vs_UI_Layer 静态公开方法,主要用于各层之间共享的信息，如层的Z坐标
MyClass.Private_vs_UI_Layer = new function () {
	var S = this;
	$vs11.copyToObject(vs11.UI.BaseControl, this);
	var LAYER_BASE = 600;
	var LAYER_KEEP_TOP_BASE = 60000;
	var LAYER_STEP = 5;
	var KeepTopLayerIndexNow = LAYER_KEEP_TOP_BASE;
	var LayerZIndexNow = LAYER_BASE;
	var LayerArray = [];
	//#region 事件Actived
	$vs11.addEvent(S, "Actived");    //active one layer
	//#endregion

	S.NewLayer = function (layer) {
		///<returns type="Number"></returns>
		var layerZIndex = LayerZIndexNow;
		LayerZIndexNow += LAYER_STEP;
		LayerArray.push(layer);
		return layerZIndex;
	}
	S.NewTopLayer = function (layer) {
		var layerZIndex = KeepTopLayerIndexNow;
		KeepTopLayerIndexNow += LAYER_STEP;
		return layerZIndex;
	}
	S.ToActiveLayer = function (layerMe) {
		var myZIndex = layerMe.get_ZIndex();
		for (var i = 0, count = LayerArray.length; i < count; i++) {
			var layer = LayerArray[i];
			var layerZIndex = layer.get_ZIndex();
			if (layerZIndex == myZIndex) {
				layer.set_ZIndex(LayerZIndexNow - LAYER_STEP);
			} else if (layerZIndex > myZIndex) {
				layer.set_ZIndex(layerZIndex - LAYER_STEP);
			}
		}
		S.Actived(layerMe);
	}
	S.DeleteLayer = function (layerMe) {
		var myZIndex = layerMe.get_ZIndex();
		for (var i = 0, count = LayerArray.length; i < count; i++) {
			var layer = LayerArray[i];
			var layerZIndex = layer.get_ZIndex();
			if (layerZIndex == myZIndex) {
				LayerArray.splice(i, 1);
				break;
			}
		}
	}
}
//#endregion
MyClass.Demo = new MyClass();
//#region vs11.UI.TreeNode 树节点的构造控件 仅继承依赖vs11.UI.BaseControl
//需准确配置$vs.config.rootPath,并准备vs11skin文件夹
MyClass = vs11.UI.TreeNode = function (args) {
	//#region 类型化,支持受保护的继承变量域
	if (args == null) args = {}; var q = (this.Inheriting) ? args : {}; this.Inheriting = true;
	vs11.UI.BaseControl.apply(this, [q]); var $vs = $vs11, vs = vs11;
	var protected$ = q, Me = public$ = this, v = private$ = {}//, base$ = $vs.copyObject(q);
	var acts = q.Acts, nodes = q.Nodes, config = q.Config = {}, info = q.Info = {};
	//#endregion
	//#region 事件 Expanded Folded NeedLoadChilds Focused Blured
	$vs.addEvent(Me, "Expanded"); //已经取消折叠状态
	$vs.addEvent(Me, "Folded"); //已经进入折叠状态
	$vs.addEvent(Me, "NeedLoadChilds"); //需要加载子节点
	$vs.addEvent(Me, "Focused"); //选中了
	$vs.addEvent(Me, "Blured"); //取消选中
	//#endregion
	//#region 容器节点
	nodes.TopNode = dom.LI;
	nodes.LineTable = dom.Table;
	nodes.FoldedImage = dom.Image;
	nodes.EndImage = dom.Image;
	nodes.ExpandedImage = dom.Image;
	nodes.Ico = dom.Label;
	nodes.Link = dom.A;
	nodes.LoadingImage = dom.Image;
	//#endregion
	//#region 配置
	config.ImageFolder = $vs.server.mapPath("~/vs11skin/default/vs_Tree/");
	config.ExpandedImage = config.ImageFolder + "o.gif";
	config.FoldedImage = config.ImageFolder + "c.gif";
	config.EndImage = config.ImageFolder + "e.gif";
	config.LoadingImage = config.ImageFolder + "s.gif";
	//#endregion
	//#region 运行时信息
	info.ParentNode = null;
	info.ChildNodes = [];
	info.AutoExpand = false;
	info.ViewIco = true;
	info.Expanded = false;
	info.NeedLoadChild = false;
	//#endregion

}
MyClass.Demo = new MyClass();
//#endregion
//*******************控件**************************

